Repository navigation
Method to keep objects in front - #840
Merged
Merged
Conversation
stickler-ci
reviewed
Apr 2, 2018
|
|
||
| def keep_in_front(self, *args): | ||
| """Pass one or multiples object that must stay in front. | ||
|
|
There was a problem hiding this comment.
W293 blank line contains whitespace
| """Pass one or multiples object that must stay in front. | ||
|
|
||
| The ordering matters, the last one is put on top. | ||
|
|
There was a problem hiding this comment.
W293 blank line contains whitespace
|
|
||
| Parameters | ||
| ---------- | ||
| *args : |
| Parameters | ||
| ---------- | ||
| *args : | ||
| Variable length argument list. Any folium object that counts as an |
| for obj in args: | ||
| self.objects_to_stay_in_front.append(obj) | ||
|
|
||
|
|
Member
|
@Conengmo this is a simple and elegant solution! Thanks!! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is an approach to tackle #826. I wanted to make something so that a user can select an object that should always stay in front.
At first I thought of adding this as an argument when creating objects, but that would mean touching many classes and a lot of repeated code and docstrings. This would be most in line with how folium currently works, but I'm not sure if its worth it for a feature that may not be used that much.
Then I looked into adding a method to a base class such as
Element, so a user can call it on any type of object. But that would mean adding Leaflet code to Branca, which I assume is not the purpose of Branca. Alternatively I could add a method toLayerin folium, but then it would not work for objects such asMarker.So finally I went for adding this method to
Map. This makes sense to me, a user is telling the map which objects it wants to keep in front. It's a separate method, so it shouldn't confuse new users, but its there if someone needs it.Here's a code snippet to test the functionality: